<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>学生基本信息</title>
    <link rel="stylesheet" th:href="@{/css/layui.css}" media="all">
    <script th:src="@{/js/layui.js}"></script>
    <!-- Fav  Icon Link -->
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <!-- themify icons CSS -->
    <link rel="stylesheet" th:href="@{/css/themify-icons.css}">
    <!-- Animations CSS -->
    <link rel="stylesheet" th:href="@{/css/animate.css}">
    <!-- Main CSS -->
    <link rel="stylesheet" th:href="@{/css/styles.css}">
    <link rel="stylesheet" th:href="@{/css/green.css}" id="style_theme">
    <link rel="stylesheet" th:href="@{/css/responsive.css}">
    <!-- morris charts -->
    <link rel="stylesheet" th:href="@{/charts/css/morris.css}">
    <!-- jvectormap -->
    <link rel="stylesheet" th:href="@{/css/jquery-jvectormap.css}">
    <link rel="stylesheet" th:href="@{/datatable/dataTables.bootstrap4.min.css}">
    <script th:src="@{/js/modernizr.min.js}"></script>
</head>
<body>
<!-- Pre Loader -->
<div class="loading">
    <div class="spinner">
        <div class="double-bounce1"></div>
        <div class="double-bounce2"></div>
    </div>
</div>

<div class="container">

    <div class="row">
        <!-- Widget Item -->
        <div class="col-md-12">
            <div class="widget-area-2 lochana-box-shadow">
                <h3 class="widget-title">基本信息</h3>
                <form class="layui-form" action="/studentMessage/updateStudent" method="post">
                    <div class="layui-form-item">
                        <div class="form-row">
                            <div class="form-group col-md-6">
                                <label for="stu_name">姓名</label>
                                <input type="text" class="form-control" placeholder="stu_name" id="stu_name"
                                       name="stu_name" th:value="${student.stu_name}"  readonly="true">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="stu_id">学号</label>
                                <input type="text" class="form-control" placeholder="stu_id" id="stu_id"
                                       name="stu_id" th:value="${student.stu_id}"  readonly="true">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="stu_sex">性别</label>
                                <input class="form-control" id="stu_sex" name="stu_sex" th:value="${student.stu_sex}"  readonly="true">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="id_card">身份证号码</label>
                                <input type="text" placeholder="id_card" class="form-control"
                                       id="id_card" name="id_card" th:value="${student.id_card}"  readonly="true">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="hou_id">宿舍楼</label>
                                <input class="form-control" id="hou_id" name="hou_id" th:value="${student.hou_id}"  readonly="true">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="dor_id">寝室</label>
                                <input class="form-control" id="dor_id" name="dor_id" th:value="${student.dor_id}"  readonly="true">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="stu_enr">入学日期</label>
                                <input type="date" placeholder="stu_enr" class="form-control"
                                       id="stu_enr" name="stu_enr" th:value="${student.stu_enr}"  readonly="true">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="stu_birth">出生日期</label>
                                <input type="date" placeholder="stu_birth" class="form-control"
                                       id="stu_birth" name="stu_birth" th:value="${student.stu_birth}"  readonly="true">
                            </div>

                            <div class="form-group col-md-6">
                                <label for="stu_study">专业</label>
                                <input type="text" placeholder="stu_study" class="form-control"
                                       id="stu_study" name="stu_study" th:value="${student.stu_study}"  readonly="true">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="stu_class">班级</label>
                                <input type="text" placeholder="stu_class" class="form-control"
                                       id="stu_class" name="stu_class" th:value="${student.stu_class}"  readonly="true">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="stu_cname">辅导员</label>
                                <input type="text" placeholder="stu_cname" class="form-control" id="stu_cname"
                                       name="stu_cname" th:value="${student.stu_cname}"  readonly="true">
                            </div>

                            <div class="form-group col-md-6">
                                <label for="stu_polit">政治面貌</label>
                                <input class="form-control" id="stu_polit" name="stu_polit" th:value="${student.stu_polit}"  readonly="true">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="stu_add">家庭住址</label>

                                <input type="text" placeholder="stu_add" class="form-control"
                                       id="stu_add" name="stu_add" lay-verify="required" autocomplete="off" th:value="${student.stu_add}" >

                            </div>
                            <div class="form-group col-md-6">
                                <label for="email">邮箱</label>

                                <input type="text" placeholder="email" class="form-control" id="email"
                                       name="email" lay-verify="required|email" autocomplete="off" th:value="${student.email}" >

                            </div>
                            <div class="form-group col-md-6">
                                <label for="stu_tel">联系方式</label>

                                <input type="text" placeholder="stu_tel" class="form-control"
                                       id="stu_tel" name="stu_tel" lay-verify="required|phone" autocomplete="off" th:value="${student.stu_tel}">

                            </div>
                            <div class=" layui-upload">
                                <div class="layui-upload-list">
                                    <img class="layui-upload-img" name="photo"  th:src="'data:image/PNG;base64,'+${photo}" style="width: 80px;height: 100px;margin-left: 100px" id="demo2" >
                                    <div class="layui-inline layui-word-aux">
                                        图片大小不能超过64KB
                                    </div>
                                    <button type="button" class="layui-btn" id="test1">上传个人照片</button>

                                </div>
                            </div>
                            <input type="hidden" id="msg" th:value="${message}" >
                            <!--<p style="margin-left: 500px" th:text="${message}"></p>-->
                            <div class="layui-form-item">
                                <div style="margin-left: 500px" class="layui-input-block">
                                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>

            </div>
        </div>
    </div>
</div>

<!-- /Back to Top -->
<!-- Jquery Library-->
<script th:src="@{/js/jquery-3.2.1.min.js}"></script>
<!-- Popper Library-->
<script th:src="@{/js/popper.min.js}"></script>
<!-- Bootstrap Library-->
<script th:src="@{/js/bootstrap.min.js}"></script>
<!-- Datatable  -->
<script th:src="@{/datatable/jquery.dataTables.min.js}"></script>
<script th:src="@{/datatable/dataTables.bootstrap4.min.js}"></script>
<!-- Custom Script-->
<script th:src="@{/js/custom.js}"></script>
<script th:src="@{/js/custom-datatables.js}"></script>

<script th:inline="javascript">

    layui.use(['form', 'layedit', 'laydate',"upload"], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,form = layui.form;

        //设定文件大小限制
        var uploadInst = upload.render({
            elem: '#test1'
            ,size: 64
            ,url: '/studentMessage/addPhoto' //上传接口
            ,method:'post'
            ,accept:'images'
            ,acceptMime:'image/*'
            ,field:'projectImg'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                    window.location.href = "/studentMessage/showMessage";
                }else {
                    window.location.href = "/studentMessage/showMessage"; //上传成功
                }

            }
            /*,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }*/
        });
    });
    onload=function(){
        var msg =  $("#msg").val();
        if (msg){
            alert(msg);
        }

    };
</script>


</body>
</html>